package com.test.mode1.controller;

import com.test.mode1.pojo.modeMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/mode1")
public class mode1Controller {
    @Autowired
    private modeMessage message;
    @Autowired
    private RestTemplate restTemplate;
    @GetMapping("/name")
    public modeMessage checkMode(){
        List<String> list = new ArrayList<>();
        list.add("mode1");

        String url = "http://mode2/mode2/name";
        String message2= restTemplate.getForObject(url, String.class);
        list.add(message2);
        message.setMode(list);

        return message;
    }
}
